<?php
Class Housing_model extends CI_Model {
  
  function gethousebyid($id) {
    $sql = "Select id_casa, ds_casa, ds_detalle from Casas where id_casa = '$id'";
    $query = $this->db->query($sql);
    return $query->result();
  }

  function gethousesbydorp($id) {
    $sql = "SELECT c.id_casa, c.ds_casa, c.ds_detalle FROM CasasProgramas cp INNER JOIN Casas c on c.id_casa = cp.id_casa WHERE cp.id_programa = '$id'";
    $query = $this->db->query($sql);
    return $query->result();
  }

  //Saves an house into the database
  function save($houseid, $housenum, $detail, $housedorp) {
	  $sql = "Save_House '$houseid', '$housenum', '$detail', '$housedorp'";
    $query = $this->db->query($sql);
    return $query->num_rows();
  }

}
?>